<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta charset="utf-8" />
    <title>后台管理-后台用户添加</title>

    <meta name="keywords" content="{$Think.CONFIG.keywords}" />
    <meta name="description" content="{$Think.CONFIG.description}" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />

    <include file="Public/head" />
</head>

<body class="no-skin">
<include file="Public/header" />
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try{ace.settings.check('main-container' , 'fixed')}catch(e){}
    </script>

    <include file="Public/sidebar" />
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <include file="Public/breadcrumbs" />

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <include file="Public/set" />

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <div class="form-horizontal">
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="username"> 用户名 <span class="required">*</span> </label>
                                <div class="col-sm-9">
                                    <input type="text" name='username' id='username' class="rcol-xs-10 col-sm-5" placeholder="用户名" value="">
                                </div>
                            </div>

                            <div class="space-4"></div>



                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="password"> 用户密码 <span class="required">*</span> </label>
                                <div class="col-sm-9">
                                    <input type="password" name="password" id="password" placeholder="密码只能由数字和字母组成,至少6位" class="col-xs-10 col-sm-5" value="">
                                </div>
                            </div>

                            <div class="space-4"></div>

                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="pwd"> 确认密码 <span class="required">*</span> </label>
                                <div class="col-sm-9">
                                    <input type="password" name="pwd" id="pwd" placeholder="再次输入密码" class="col-xs-10 col-sm-5" value="">

                                </div>
                            </div>

                            <div class="space-4"></div>

                            <div class="col-md-offset-2 col-md-9">
                                <button class="btn btn-info" type="button" onclick='save();'>
                                    <i class="icon-ok bigger-110"></i>
                                    提交
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn btn-info" type="button" onclick='fan();'>
                                    <i class="icon-ok bigger-110"></i>
                                    返回
                                </button>
                            </div>
                        </div>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <include file="Public/footer" />

</div><!-- /.main-container -->

<include file="Public/footerjs" />
<!-- inline scripts related to this page -->
<script src="__PUBLIC__/qwadmin/js/date-time/bootstrap-datepicker.js"></script>
<script src="__PUBLIC__/qwadmin/js/function.js"></script>
<script type="text/javascript">
    function fan(){
        var urls = "{:U('AdminUser/index')}";
        window.location.href=urls;
    }
    function save(){
        var username = $('#username').val();
        var password = $('#password').val();
        var pwd = $('#pwd').val();
        var urls = "{:U('AdminUser/index')}";
        if(username == ''){
            bootbox.dialog({
                title: '友情提示：',
                message: "用户名必须填写。",
                buttons: {
                    "success" : {
                        "label" : "确定",
                        "className" : "btn-danger"
                    }
                }
            });
            return;
        }
        if(password.length<6){
            bootbox.dialog({
                title: '友情提示：',
                message: "密码至少6位",
                buttons: {
                    "success" : {
                        "label" : "确定",
                        "className" : "btn-danger"
                    }
                }
            });
            return;
        }
        var reg = /^[0-9a-zA-Z]+$/;
        if(!reg.test(password)){
            bootbox.dialog({
                title: '友情提示：',
                message: "密码只能由数字和字母组成",
                buttons: {
                    "success" : {
                        "label" : "确定",
                        "className" : "btn-danger"
                    }
                }
            });
            return;
        }
        if(password != pwd){
            bootbox.dialog({
                title: '友情提示：',
                message: "两次密码输入不一致！",
                buttons: {
                    "success" : {
                        "label" : "确定",
                        "className" : "btn-danger"
                    }
                }
            });
            return;
        }
        $.ajax({
            type: "post",
            url: "{:U('AdminUser/doadd')}",
            data: "username="+username+"&password="+password,
            success: function(data){
                if(data.status == 1){
                    alert('添加成功');
                    window.location.href=urls;
                }else{
                    alert('添加失败！');
                }
            }
        });
    }
</script>
</body>
</html>
